<template>
	<view class="page">
		<uni-section type="line" title="查询条件">
			<view class="form">
				<uni-forms label-position="top" label-width="120">
					<uni-forms-item label="用户手机号" name="phone">
						<uni-easyinput type="text" v-model="phone" placeholder="请输入用户手机号" />
					</uni-forms-item>
					<uni-forms-item label="处理状态" name="state">
						<uni-data-picker placeholder="请选择处理状态" popup-title="请选择处理状态" :localdata="stateList" v-model="state" />
					</uni-forms-item>
				</uni-forms>
			</view>
		</uni-section>
		<view class="form-btn">
			<button type="warn" @click="reset">重置</button>
			<button type="primary" @click="submit">提交</button>
		</view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				stateList: [
					{ value: 0, text: "全部" },
					{ value: 1, text: "已处理" },
					{ value: 2, text: "未处理" }
				],
				phone: '',
				state: '',
			}
		},
		
		methods: {
			reset() {
				this.phone= ''
				this.state= ''
				this.submit()
			},
			
			submit() {
				let data = {
					phone: this.phone,
					state: this.state
				}
				
				let pages = getCurrentPages(); // 当前页面
				
				let beforePage = pages[pages.length - 2]; // 上一页
				
				uni.navigateBack({
					success: function() {
						beforePage.$vm.setSearch(data); // 执行上一页的onLoad方法
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		height: 100vh;
		background-color: #fff;
	}
	
 .form {
	 padding: 20rpx;
 }
 
 .form-btn {
	 width: 100%;
	 box-sizing: border-box;
	 position: absolute;
	 bottom: 80rpx;
	 padding: 10rpx;
	 display: flex;
	 align-items: center;
		
		button {
			width: 320rpx;
		}
 }
</style>